package com.example.asus.logactivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class LogActivity extends Activity {
    /* 在创建活动时调用 */
    private Button myButtton;
    /*我们在每个方法中定义Log.v("","")要与声明的字符常量LIFT_TAG一致*/
    static final String LIFT_TAG="LogActivity";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.v(LogActivity.LIFT_TAG, "FirstAcvity ---> onCreate//创建LogActivity");
        Button myButton = (Button)findViewById(R.id.myButton);
        myButton.setText("启动第二个Activity");
        myButton.setOnClickListener(new ButtonOnClickListener());
    }

    class ButtonOnClickListener implements OnClickListener{
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(LogActivity.this,LogActivity2.class);
            LogActivity.this.startActivity(intent);
        }
    }
    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        Log.v(LogActivity.LIFT_TAG,"FirstAcvity --->onDestory//退出app，LogActivity被销毁");
        super.onDestroy();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        Log.v(LogActivity.LIFT_TAG, "FirstAcvity --->onPause//当启动其他LogActivity时，先暂停");
        super.onPause();
    }

    @Override
    protected void onRestart() {
        // TODO Auto-generated method stub
        Log.v(LogActivity.LIFT_TAG, "FirstAcvity --->onRestart//重新开始执行LogActivity，接着调用onStart()，onResume（）方法");
        super.onRestart();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        Log.v(LogActivity.LIFT_TAG, "FirstAcvity --->onResume//LogActivity开始真正的运行了");
        super.onResume();
    }

    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        Log.v(LogActivity.LIFT_TAG, "FirstAcvity --->onStart//LogActivity开始被执行");
        super.onStart();
    }

    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        Log.v(LogActivity.LIFT_TAG, "FirstAcvity --->onStop//当LogActivity2开始被执行时，LogActivity被暂停了，但没有被销毁");
        super.onStop();
    }
}